<?php
namespace app\admin\controller;
use app\admin\model\User as UserModel;
use app\admin\controller\Base;

class User extends Base
{
    public function index()
    {
         $list=db('user')->field('u.*,i.*')->alias('u')->join('f_information i','u.id=i.userid')->order('u.id')->paginate(5);
        $this->assign('list',$list);
        $this->assign('title', '会员列表');
        return view();
    }

    public function see()
    {
        $id=input('id');
        $list=db('information')->where('id',$id)->find();
       /* var_dump($list);
        die;*/
        $this->assign('list',$list);
        return view();
    }
    
     public function onstatus()
    {
        $id = input('id');
        $user = db('information')->find($id);
        if ($user['status'] == 1) {
            $data = [
                'id' => $id,
                'status' => 0,
            ];
            db('information')->update($data);
            $this->redirect('index');
        } else {
            $data = [
                'id' => $id,
                'status' => 1,
            ];
            db('information')->update($data);
            $this->redirect('index');
        }
    }

    public function ontype()
    {
        $id = input('id');
        $user = db('information')->find($id);
        if ($user['type'] == 0) {
            $data = [
                'id' => $id,
                'type' => 1,
            ];
            db('information')->update($data);
            $this->redirect('index');
        } elseif($user['type'] == 1) {
            $data = [
                'id' => $id,
                'type' => 2,
            ];
            db('information')->update($data);
            $this->redirect('index');
        }else{
            $data = [
                'id' => $id,
                'type' => 0,
            ];
            db('information')->update($data);
            $this->redirect('index');
        }
    }

    
    
}

